#pragma once

#include "rewine/impl/CImage.hpp"

#include <list>
#include <memory>
#include <string>
#include <utility>

namespace rewine
{

class CCustomImageExportEntry {
public:

    std::string symbolName;
    std::shared_ptr<IExport> pExport;

public:

    explicit CCustomImageExportEntry(std::string symbolName, std::shared_ptr<IExport> pExport)
        : symbolName(std::move(symbolName)), pExport(std::move(pExport)) {}

    explicit CCustomImageExportEntry(std::string&& symbolName, std::shared_ptr<IExport>&& pExport)
        : symbolName(std::move(symbolName)), pExport(std::move(pExport)) {}

};

class CCustomImage : public CImage {
private:

    using list_t = std::list<std::shared_ptr<CCustomImageExportEntry>>;
    list_t m_Exports;

private:

    list_t::iterator find(const std::string& symbolName);
    list_t::const_iterator find(const std::string& symbolName) const;

public:

    explicit CCustomImage(const std::string& exportName);
    ~CCustomImage() override = default;

public:

    void set(const std::string& symbolName, std::shared_ptr<IExport> pExport);
    bool remove(const std::string& symbolName);

    ImageFlavour flavour() const override {
        return ImageFlavour::CUSTOM;
    }

    int getExportCount() const override;
    IExport * getExportByIndex(unsigned int index) const override;
    IExport * getExportByName(const std::string& name, uint16_t hint) const override;

};

}
